// 关闭广告功能
var btn = document
  .querySelector(".J_event")
  .querySelector("a")
  .querySelector("i");
var J_event = document.querySelector(".J_event");
// 获取搜索框
var search = document.querySelector(".search").querySelector("input");

//关闭广告功能函数函数
function close(element, closeElement) {
  element.addEventListener("click", function () {
    closeElement.style.display = "none";
  });
}
close(btn, J_event);

// 搜索框获取焦点功能函数
function SearchBoxEvents(element) {
  element.addEventListener("focus", function () {
    this.value = "";
  });
  element.addEventListener("blur", function () {
    this.value = "单反相机";
  });
}
SearchBoxEvents(search);

// 循环精灵图
var spriteMap = document.getElementsByClassName("spriteMap");
console.log(spriteMap);
for (var i = 0; i < spriteMap.length; i++) {
  spriteMap[i].style.backgroundPosition = "-" + i * 44 + "px 0";
}
